package com.jialiang.common.exception;


import com.jialiang.common.constants.BaseEnum;
import lombok.Getter;
import lombok.Setter;

/**
 * 强制业务异常必须提供code码，便于统一维护
 */
public class BusinessException extends RuntimeException {

  @Getter
  private final BaseEnum serviceCode;

  @Getter
  @Setter
  private Object data;

  public BusinessException(BaseEnum serviceCode) {
    super(serviceCode.getName());
    this.serviceCode = serviceCode;
  }

  public BusinessException(BaseEnum serviceCode, Object data) {
    super(serviceCode.getName());
    this.serviceCode = serviceCode;
    this.data = data;
  }

  public BusinessException(BaseEnum serviceCode, String data) {
    super(data);
    this.serviceCode = serviceCode;
  }

}
